import { IPageRequest, IPageResponse } from 'src/common/utils/types';
import { ApiProperty } from '@nestjs/swagger';
import { ResponsePlayerSignupDto } from './response-player-signup.dto';
import {
  IsArray,
  IsNumber,
  IsObject,
  IsOptional,
  IsString,
} from 'class-validator';
import { ResponsePairDto } from './response-pair.dto';

class SearchParamDto {
  @ApiProperty({ type: Number, description: '年龄组Id', required: true })
  @IsNumber()
  categoryId?: number;

  @ApiProperty({
    oneOf: [{ type: 'number' }, { type: 'array', items: { type: 'number' } }],
    description: '赛事ID列表',
    required: false,
  })
  @IsOptional()
  @IsArray()
  @IsNumber({}, { each: true })
  eventIds: number[];

  @ApiProperty({ type: String, description: '选手姓名', required: false })
  @IsOptional()
  @IsString()
  name: string;

  @ApiProperty({ type: String, description: '团队赛团队ID', required: false })
  @IsOptional()
  @IsString()
  parentPlayerId: string;
}

export class SearchPlayerDto {
  @ApiProperty({
    type: Number,
    description: '每页显示的记录数量',
    required: true,
    default: 10,
  })
  @IsOptional()
  @IsNumber()
  size?: number = 10;

  @ApiProperty({
    type: Number,
    description: '请求页码',
    required: true,
    default: 1,
  })
  @IsOptional()
  @IsNumber()
  page?: number = 1;

  @ApiProperty({
    type: SearchParamDto,
    description: '查询参数',
    required: true,
  })
  @IsObject()
  param: SearchParamDto;
}
export class SearchPlayerResponseDto {
  // implements IPageResponse<ResponsePlayerSignupDto>
  @ApiProperty({
    type: Number,
    description: '总记录数',
  })
  total: number;
  @ApiProperty({
    type: [ResponsePlayerSignupDto],
    description: '选手报名信息列表',
  })
  data: ResponsePlayerSignupDto[];
  @ApiProperty({
    type: Number,
    description: '当前页码',
  })
  page: number;
}
export class SearchPairResponseDto {
  @ApiProperty({
    type: Number,
    description: '总记录数',
  })
  total: number;
  @ApiProperty({
    type: Number,
    description: '当前页码',
  })
  page: number;
  @ApiProperty({
    type: [ResponsePairDto],
    description: '选手报名信息列表',
  })
  data: ResponsePairDto[];
}
